<template>
  
  <RouterView />
  
</template>
<script setup>
import { RouterView,useRouter } from 'vue-router';
import { onMounted, onUnmounted } from 'vue'
import socket from '@/utils/socket';
import {useBeforeunload} from '@/hooks/useBeforeunload';
const router = useRouter()
// 浏览器刷新时关闭websocket
useBeforeunload(socket.close)

onMounted(() => {
  socket.init(router)
});


onUnmounted(() => {
  socket.close()
});
</script>
<style lang="scss">
#app {
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  background-color: rgba(0,0,0,.6);
}
</style>